<extend name="base/Base" />
<block name="Style">
<!-- FooTable Plugin CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/vendor/plugins/footable/css/footable.core.min.css">
		<!-- Admin Forms CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/assets/admin-tools/admin-forms/css/admin-forms.css">
		<js href="__ADDON__/ajaxupload/js/jquery.js" />
		<js href="__ADDON__/ajaxupload/js/ajaxupload.js" />
		<script type="text/javascript">
		$(function(){
			var button = $('#upload_button'), interval;
			var confirmdiv = $('#uploadphotoconfirm');
			var fileType = "pic",fileNum = "one"; 
			new AjaxUpload(button,{
				action: "__APP__/Home/Upload/Image/Addon/AjaxUpload.html",
				name: 'userfile',
				onSubmit : function(file, ext){
					if(fileType == "pic")
					{
						if (ext && /^(jpg|png|jpeg|gif|JPG)$/.test(ext)){
							this.setData({
								'info': '文件类型为图片'
							});
						} else {
							 confirmdiv.text('文件格式错误，请上传格式为.png .jpg .jpeg 的图片');
							return false;               
						}
					}
								
					confirmdiv.text('文件上传中');
					
					if(fileNum == 'one')
						this.disable();
					
					interval = window.setInterval(function(){
						var text = confirmdiv.text();
						if (text.length < 14){
							confirmdiv.text(text + '.');                    
						} else {
							confirmdiv.text('文件上传中');             
						}
					}, 200);
				},
				onComplete: function(file, response){
					if(response != "success"){
						if(response =='2'){
							confirmdiv.text("文件格式错误，请上传格式为.png .jpg .jpeg 的图片");
						}else{
							
							confirmdiv.text("上传完成");
							
							$("#newbikephotoName").val(response);
							$("#newbikephoto").attr("src",response);	
							$("#imgurl").attr("value",response);						
							
						}
						
					}
										  
					window.clearInterval(interval);
								
					this.enable();
					
					if(response == "success")
					alert('上传成功');              
				}
			});
		});
		</script>

</block>
<block name="Topbar">
 <header id="topbar" class="ph10">
        <div class="topbar-left">
          <ul class="nav nav-list nav-list-topbar pull-left">
            <li>
              <a href="#"  data-toggle="modal" data-target="#myModal" >新增导航</a>
            </li>
            <li  class="active" >
              <a  href="#"   >导航管理</a>
            </li>
           
          </ul>
        </div>
        <div class="topbar-right hidden-xs hidden-sm">
		 <a href="#"  onclick="selectAll()" class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-star pr5"></span>全选</a>
			 <a href="#"   onclick="unSelect()"  class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-star-o pr5"></span>不选</a>
			 <a href="#"    onclick="reverse()"class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-star-half-o pr5"></span>反选</a>
			  
			
			
			  <a href="#" onclick="status(0)" class="btn btn-default btn-sm fw600 ml10">
				<span class="fa fa-trash-o pr5"></span>删除</a>
			 
						  
          
        </div>
      </header>
      
</block>
<block name="Content">
	 <!-- begin: .tray-center -->
        <div class="row">

        <!-- Panel with: Data Filter -->
          <div class="col-md-12" id="spy2" >
            <div class="panel-heading">
              <span class="panel-title">
                <span class="fa fa-search"></span>导航信息</span>
               <div class="pull-right">
			 				
            <!--    <a  href="#" data-toggle="modal" data-target="#myModal" class="btn btn btn-primary">新增导航</a>						
								
							 -->	<!-- Modal -->
									<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
									  <div class="modal-dialog" role="document">
										<div class="modal-content">
										  <div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="myModalLabel">新增导航</h4>
										  </div>
										  <div class="modal-body">
										    <form class="form-horizontal" role="form">
					
				<div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">导航名称</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="name" id="name" class="form-control input-lg" placeholder="请输入导航名称">
                      </div>
                    </div>
                  </div>
				 
				  
                
				
                  <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">导航链接</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="url" id="url" class="form-control input-lg" placeholder="请输入导航链接">
                      </div>
                    </div>
                  </div>
				  
				 
				   <div class="form-group">
				   <label for="inputSelect" class="col-lg-3 control-label" style="padding-top:0px;">链接类型</label>
					 
				 <label class="radio-inlines" style="padding-left:10px;">
				  <input type="radio" name="type" value="1" checked> 内部链接
					</label>
					
					<label class="radio-inlines" style="padding-left:10px;">
					  <input type="radio" name="type"  value="2">外部链接
					</label>
				
				</div>
				
				
				
				   <section>
						<label class="control-label" for="bike_type">&nbsp;</label>
							<input type="file" style="display:none" name="userfile">
							<input type="hidden" id="newbikephotoName" name="img" value="" />
							<input type="hidden" id="oldbikephotoName" value="" />
							<div class="controls" style="text-align:center;">
								<img  id="newbikephoto" src="http://image.zaiyoudao.com/image.php/zyd_126.html" style="max-height:200px;max-width:200px;" />
								<span class="help-inline"></span>
								<br>
								<div id="uploadphotoconfirm"></div>
								<br>
								<input type="hidden" name="img" id="imgurl" value="" style="max-height:200px;max-width:200px;"  >
								<input type="button" class="btn btn-lg btn-primary" style="width:50%" id="upload_button"  value="上传缩略图" /><br/>
								
							</div>
					</section>
					<br>
				   <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" style="padding-top:0px;">导航排序</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="number" name="sort" id="sort"  class="form-control input-lg" placeholder="请输入导航排序">
                      </div>
                    </div>
                  </div>
				  
				   <div class="form-group">
				   <label for="inputSelect" class="col-lg-3 control-label" style="padding-top:0px;">打开方式</label>
					 
				 <label class="radio-inlines" style="padding-left:10px;">
				  <input type="radio" name="target" value="1" checked> 当前页面
					</label>
					<label class="radio-inlines" style="padding-left:10px;">
					  <input type="radio" name="target"  value="2"> 新页面
					</label>
					
				</div>
				
                </form>
              			
						
										  </div>
										  <div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
											<a href="#" class="btn btn-primary" onclick="create()" >新增导航</a>
											
										  </div>
										</div>
									  </div>
									</div>
								<script>
						
							//新增导航
							function create(){  
							
								var name = $("#name").val();
								var url = $("#url").val();
								var type = $("input[name='type']:checked").val();
							
								var sort = $("#sort").val();
								var target = $("input[name='target']:checked").val();
								var img = $("#newbikephotoName").val();
								
								$.ajax({
									type:'POST',
									url:"__APP__/Admin/Nav/Create.html",
									data:{
										
										"fnid": {$fnid},
										"tier": {$tier},
										"name": name,
										"url": url,
										"type": type,
										"sort": sort,
										"img": img,
										"target": target,
										
									},
									success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
									},
									error:function(){
										layer.msg('系统繁忙,请稍候重试！');
									}
								
								});	 
							}  
							
							function AJAXDelete(id){  
								if(confirm('是否确认删除')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Delete.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('删除成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXOutage(id){  
								if(confirm('是否确认隐藏')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Outage.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('隐藏成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXEnabled(id){  
								if(confirm('是否确认显示')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Enabled.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('显示成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							</script>
							
              </div> 
            </div>
            <div class="panel-menu">
              <input id="fooFilter" type="text" class="form-control" placeholder="请输入搜索的关键字">
            </div>
            <div class="panel-body pn">
              <table class="table footable" data-filter="#fooFilter"  data-page-navigation=".pagination" data-page-size="100">
               <thead>
												<tr>
													
													<th style="width:4%;">批量</th>
													<th >#</th>
												
													<th >上层</th>
													<th>导航</th>
													<th>层级</th>
													<th>图片</th>
													
													<th >类型</th>
													<th >链接</th>
													<th >打开</th>
													<th >排序</th>
													<!-- <th >状态</th>
													 -->
													<th >编辑</th>
												</tr>
											</thead>
											<tbody>
												<volist name="list" id="list">
												<tr>
													<td class="text-center">
													<center>
														<label class="option block mn">
														  <input type="checkbox" id="batch" name="batch" value="{$list.id}">
														
														</label>
														</center>
													  </td>
													<td>{$i}</td>
													<td>
													<if condition="$data.tier eq 1"> 
														
														<a href="__APP__/Admin/Nav/Manage/fnid/{$data.fnid}.html">	{$data.name|default="顶级导航"}</a>
													
														
													
													<else /> 
													
														{$data.name|default="顶级导航"}
													
														
													</if>
													
													
													</td>
													
													<td><a href="__APP__/Admin/Nav/Manage/fnid/{$list.id}.html">{$list.name}</a></td>
													<td>{$list.tier}</td>
													<td><img src="{$list.img}" style="width:25px;height:25px;"></td>
													
													<td>
													<if condition="$list.type eq 1"> 
													内部链接
													<elseif condition="$list.type eq 2"/> 
													外部连接
													<elseif condition="$list.type eq 4"/> 
													操作行为
													<elseif condition="$list.type eq 3"/> 
													小组组标
													<else />
													未知
													</if>
													</td>
													<td>{$list.url}</td>
													<td>
													<if condition="$list.target eq 1"> 
													当前页面
													<elseif condition="$list.target eq 2"/> 
													新窗口
													
													<else />
													未知
													</if>
													</td>
													<td>{$list.sort}</td>
													<!-- <td>
													<if condition="$list.status eq 1"> 
													<a  href="#" 
													onClick="AJAXOutage('{$list.id}')"
													class="btn btn-xs btn-success">显示</a>
													<else /> 
													<a  href="#" 
													onClick="AJAXEnabled('{$list.id}')"
													class="btn btn-xs btn-danger">隐藏</a>
													</if>
													</td> -->
													
													<td>
													
																	<a  href="#" data-toggle="modal" data-target="#myModal{$list.id}"  class="btn btn-xs btn-primary">编辑</a>
														
																					<!-- Modal -->
									<div class="modal fade" id="myModal{$list.id}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
									  <div class="modal-dialog" role="document">
										<div class="modal-content">
										  <div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="myModalLabel">编辑导航</h4>
										  </div>
										  <div class="modal-body">
										  
										    <form class="form-horizontal" role="form">
					
				<div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label" >导航名称</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="text" name="name" id="name{$list.id}" value="{$list.name}" class="form-control input-lg" placeholder="请输入导航名称">
                      </div>
                    </div>
                  </div>
				 
				  
                 
                  <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label">导航链接</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input  type="text" name="url" id="url{$list.id}" value="{$list.url}" class="form-control input-lg" placeholder="请输入导航链接">
                      </div>
                    </div>
                  </div>
				  
				  <div class="form-group">
                    <label for="inputSelect" class="col-lg-3 control-label" >链接类型</label>
                    <div class="col-lg-8" style="padding-top:2px;">
                      <div class="">
                        <select name="type{$list.id}" id="type{$list.id}" class="form-control input-lg">
                  
						  <option value="{$list.type}">保持不变</option>
						  <option value="1">内部链接</option>
						
						  <option value="2">外部链接</option>
						 
                        </select>
                      </div>
                    </div>
                  </div>
				  
				 <section>
					<label class="control-label" for="bike_type">&nbsp;</label>
						<input type="file" style="display:none" name="userfile">
						<input type="hidden" id="newbikephotoName{$list.id}" name="img" value="{$list.img}" />
						<input type="hidden" id="oldbikephotoName{$list.id}" value="" />
						<div class="controls" style="text-align:center;">
							<img  id="newbikephoto{$list.id}" src="{$list.img}" style="max-height:200px;max-width:200px;" />
							<span class="help-inline"></span>
							<br>
							<div id="uploadphotoconfirm{$list.id}"></div>
							<br>
							<input type="hidden" name="img" id="imgurl{$list.id}" value="{$list.img}" style="max-height:200px;max-width:200px;" >
							<input type="button" class="btn btn-lg btn-primary" style="width:50%" id="upload_button{$list.id}"  value="上传缩略图" /><br/>
							
						</div>
				</section>
				 <br>
				   <div class="form-group">
                    <label for="inputStandard" class="col-lg-3 control-label">导航排序</label>
                    <div class="col-lg-8"  style="padding-top:2px;">
                      <div class="">
                        <input type="number" name="sort" id="sort{$list.id}" value="{$list.sort}" class="form-control input-lg" placeholder="请输入导航排序">
                      </div>
                    </div>
                  </div>
				   <div class="form-group">
                    <label for="inputSelect" class="col-lg-3 control-label" >打开方式</label>
                    <div class="col-lg-8" style="padding-top:2px;">
                      <div class="">
                        <select name="target{$list.id}" id="target{$list.id}" class="form-control input-lg">
                  
						  <option value="{$list.target}">保持不变</option>
						  <option value="1">当前窗口</option>
						  <option value="2">新窗口</option>
						 
                        </select>
                      </div>
                    </div>
                  </div>
                </form>		
						
													<script>
						
						$(function(){
	var button = $('#upload_button{$list.id}'), interval;
	var confirmdiv = $('#uploadphotoconfirm{$list.id}');
    var fileType = "pic",fileNum = "one"; 
    new AjaxUpload(button,{
        action: "__APP__/Home/Upload/Image/Addon/AjaxUpload.html",
        name: 'userfile',
        onSubmit : function(file, ext){
            if(fileType == "pic")
            {
                if (ext && /^(jpg|png|jpeg|gif|JPG)$/.test(ext)){
                    this.setData({
                        'info': '文件类型为图片'
                    });
                } else {
                     confirmdiv.text('文件格式错误，请上传格式为.png .jpg .jpeg 的图片');
                    return false;               
                }
            }
                        
            confirmdiv.text('文件上传中');
            
            if(fileNum == 'one')
                this.disable();
            
            interval = window.setInterval(function(){
                var text = confirmdiv.text();
                if (text.length < 14){
                    confirmdiv.text(text + '.');                    
                } else {
                    confirmdiv.text('文件上传中');             
                }
            }, 200);
        },
        onComplete: function(file, response){
			if(response != "success"){
				if(response =='2'){
					confirmdiv.text("文件格式错误，请上传格式为.png .jpg .jpeg 的图片");
				}else{
					
					confirmdiv.text("上传完成");
					$("#newbikephotoName{$list.id}").val(response);
					$("#newbikephoto{$list.id}").attr("src",response);	
					$("#imgurl{$list.id}").attr("value",response);						
					
				}
				
			}
                                  
            window.clearInterval(interval);
                        
            this.enable();
            
            if(response == "success")
            alert('上传成功');              
        }
    });
});

							
							function AJAXEdit{$list.id}(id){  
								var sort = $("#sort{$list.id}").val();
								var type = $("#type{$list.id}").val();
								var name = $("#name{$list.id}").val();
								var url = $("#url{$list.id}").val();
								var target = $("#target{$list.id}").val();
								var img = $("#newbikephotoName{$list.id}").val();
								
								$.ajax({
									type:'POST',
									url:"__APP__/Admin/Nav/Edit.html",
									data:{
										"id": id,
										"sort": sort,
										"name": name,
										"url": url,
										"type": type,
										"img": img,
										"target": target,
									
									},
									success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
									},
								
								});	 
							}  
							
							
						</script> 			
						
										  </div>
										  <div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
											<a href="#" class="btn btn-primary" onclick="AJAXEdit{$list.id}({$list.id})" >编辑导航</a>
											</form>	
										  </div>
										</div>
									  </div>
									</div>
								
														
													
													
														
														
													</td>
												</tr>
												</volist>
											</tbody>
											 <tfoot class="footer-menu">
												<tr>
												  <td colspan="12">
													<nav class="text-right">
													  <ul class="pagination hide-if-no-paging"></ul>
													</nav>
												  </td>
												</tr>
											  </tfoot>

										</table>
            </div>
          </div>
		      
      </div>

		
</block>
<block name="Script">
	
  <!-- FooTable Plugin -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.all.min.js"></script>
   <!-- FooTable Addon -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.filter.min.js"></script>
  
 <script type="text/javascript">
 
	
		function unSelect(){
				
		  $("input[id='batch']").each(function(){
		   $(this).prop("checked",false);
		  });  
		  
	
		}
		
		function selectAll(){
				
		 $("input[id='batch']").each(function(){
		   $(this).prop("checked",true);
		  });  
		  
		}
		
		function reverse(){
				
		 $("input[id='batch']").each(function(){
			$(this).prop("checked",!this.checked);   
		  
			})
		}
		
		function status(status){
				
				
						 var id=$('input[id="batch"]:checked').map(function(){return this.value}).get().join();
						
						layer.confirm('你确定要这样做么？', {
						  btn: ['确定','取消'] //按钮
						}, function(){
						  
						  $.ajax({
								type:'POST',
								url:"__APP__/Admin/Nav/Delete.html",
								data:{
									
									"id": id,
									"status": status,
									
								},
								success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
								},
								error:function(){
									layer.msg('系统繁忙,请稍候重试！');
								}
							
							});	 
						  
						}, function(){
						  
						  
						});

					
				
				}
				
		  </script>
 <script type="text/javascript">
  jQuery(document).ready(function() {

 

    // Init FooTable Examples
    $('.footable').footable();


  });
  </script>
</block>